/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InterfazInicio.java
 *
 * Created on 27/12/2011, 01:39:26 AM
 */
package vista.panel;

import controlador.ControladorInterfazInicio;
import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.button.StandardButtonShaper;
import org.jvnet.substance.utils.SubstanceConstants;

/**
 *
 * @author Elias Mendoza
 */
public class InterfazInicio extends javax.swing.JPanel {
  public ControladorInterfazInicio accion;

  /** Creates new form InterfazInicio */
  public InterfazInicio() {
    
    initComponents();
    this.jButtonConectarPuerto.putClientProperty( SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY, new StandardButtonShaper());
    accion = new ControladorInterfazInicio(this);
    accion.mustraHoraFecha();
//    accion.compruebaConexionBD();
    accion.cargaPanelInicio(jPanelContenedorComportamiento);
  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPanePrincipal = new javax.swing.JScrollPane();
        jPanelPrincipal = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabelFecha = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        jLabelHora = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jButtonConectarPuerto = new javax.swing.JButton();
        jComboBoxPuertoSerial = new javax.swing.JComboBox();
        jCheckBoxPuerto = new javax.swing.JCheckBox();
        jTextFieldPuertoPerzonalisado = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jButtonSalir = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        jPanel6 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabelPuertoSerie = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabelEstadoPuerto = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jLabelEstadoBD = new javax.swing.JLabel();
        jPanel9 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPaneDatosRecibidos = new javax.swing.JTextPane();
        jSeparator2 = new javax.swing.JSeparator();
        jPanel10 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        jLabelFechaUlt = new javax.swing.JLabel();
        jPanel12 = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jLabelHoraUlt = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableRegistrosInsertados = new javax.swing.JTable();
        jPanelContenedorComportamiento = new javax.swing.JPanel();

        jPanelPrincipal.setBackground(new java.awt.Color(255, 255, 255));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 0));

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Fecha y Hora", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 13), new java.awt.Color(102, 102, 102))); // NOI18N

        jLabelFecha.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabelFecha.setForeground(new java.awt.Color(51, 51, 51));
        jLabelFecha.setText("00/00/0000");
        jPanel2.add(jLabelFecha);

        jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator3.setAlignmentX(2.0F);
        jSeparator3.setAlignmentY(2.0F);
        jPanel2.add(jSeparator3);

        jLabelHora.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabelHora.setForeground(new java.awt.Color(51, 51, 51));
        jLabelHora.setText("00-00-00 am");
        jPanel2.add(jLabelHora);

        jPanel1.add(jPanel2);

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Puerto Serial", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 13), new java.awt.Color(102, 102, 102))); // NOI18N
        jPanel3.setLayout(new java.awt.GridLayout(1, 0, 10, 5));

        jButtonConectarPuerto.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jButtonConectarPuerto.setForeground(new java.awt.Color(51, 51, 51));
        jButtonConectarPuerto.setText("Conectar");
        jButtonConectarPuerto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConectarPuertoActionPerformed(evt);
            }
        });
        jPanel3.add(jButtonConectarPuerto);

        jComboBoxPuertoSerial.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jComboBoxPuertoSerial.setForeground(new java.awt.Color(51, 51, 51));
        jComboBoxPuertoSerial.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "COM10" }));
        jPanel3.add(jComboBoxPuertoSerial);

        jCheckBoxPuerto.setBackground(new java.awt.Color(255, 255, 255));
        jCheckBoxPuerto.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jCheckBoxPuerto.setForeground(new java.awt.Color(51, 51, 51));
        jCheckBoxPuerto.setText("Editar Puerto");
        jPanel3.add(jCheckBoxPuerto);

        jTextFieldPuertoPerzonalisado.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jPanel3.add(jTextFieldPuertoPerzonalisado);

        jPanel1.add(jPanel3);

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Sistema", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 13), new java.awt.Color(102, 102, 102))); // NOI18N
        jPanel4.setLayout(new java.awt.GridLayout(1, 0, 10, 10));

        jButtonSalir.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jButtonSalir.setText("Salir");
        jButtonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalirActionPerformed(evt);
            }
        });
        jPanel4.add(jButtonSalir);

        jPanel1.add(jPanel4);

        jPanel5.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.TRAILING, 20, 5));

        jPanel6.setBackground(new java.awt.Color(255, 255, 255));
        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Estado", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 13), new java.awt.Color(102, 102, 102))); // NOI18N
        jPanel6.setLayout(new java.awt.GridLayout(1, 0));

        jPanel7.setBackground(new java.awt.Color(255, 255, 255));

        jLabel7.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabel7.setForeground(new java.awt.Color(51, 51, 51));
        jLabel7.setText("Puerto Serie:");
        jPanel7.add(jLabel7);

        jLabelPuertoSerie.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabelPuertoSerie.setForeground(new java.awt.Color(51, 51, 51));
        jLabelPuertoSerie.setText("COM0");
        jPanel7.add(jLabelPuertoSerie);

        jLabel11.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabel11.setForeground(new java.awt.Color(51, 51, 51));
        jLabel11.setText("Estado:");
        jPanel7.add(jLabel11);

        jLabelEstadoPuerto.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabelEstadoPuerto.setForeground(new java.awt.Color(51, 51, 51));
        jLabelEstadoPuerto.setText("Desconectado");
        jPanel7.add(jLabelEstadoPuerto);

        jPanel6.add(jPanel7);

        jPanel8.setBackground(new java.awt.Color(255, 255, 255));

        jLabel9.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(51, 51, 51));
        jLabel9.setText("Base Datos:");
        jPanel8.add(jLabel9);

        jLabelEstadoBD.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabelEstadoBD.setForeground(new java.awt.Color(0, 51, 204));
        jLabelEstadoBD.setText("Conectado");
        jPanel8.add(jLabelEstadoBD);

        jPanel6.add(jPanel8);

        jPanel9.setBackground(new java.awt.Color(255, 255, 255));
        jPanel9.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jTextPaneDatosRecibidos.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos Recibidos", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 13), new java.awt.Color(51, 51, 51))); // NOI18N
        jTextPaneDatosRecibidos.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jTextPaneDatosRecibidos.setForeground(new java.awt.Color(102, 102, 102));
        jScrollPane1.setViewportView(jTextPaneDatosRecibidos);

        jPanel9.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 11, 351, 308));

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator2.setFont(new java.awt.Font("Tahoma", 0, 12));
        jPanel9.add(jSeparator2, new org.netbeans.lib.awtextra.AbsoluteConstraints(371, 11, -1, 308));

        jPanel10.setBackground(new java.awt.Color(255, 255, 255));
        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Ultimo registros insertados", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 13), new java.awt.Color(102, 102, 102))); // NOI18N
        jPanel10.setLayout(new java.awt.GridLayout(1, 0));

        jPanel11.setBackground(new java.awt.Color(255, 255, 255));
        jPanel11.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 5));

        jLabel15.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabel15.setForeground(new java.awt.Color(51, 51, 51));
        jLabel15.setText("Fecha:");
        jPanel11.add(jLabel15);

        jLabelFechaUlt.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabelFechaUlt.setForeground(new java.awt.Color(51, 51, 51));
        jLabelFechaUlt.setText("fecha");
        jPanel11.add(jLabelFechaUlt);

        jPanel10.add(jPanel11);

        jPanel12.setBackground(new java.awt.Color(255, 255, 255));
        jPanel12.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 5));

        jLabel17.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabel17.setForeground(new java.awt.Color(51, 51, 51));
        jLabel17.setText("Hora:");
        jPanel12.add(jLabel17);

        jLabelHoraUlt.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabelHoraUlt.setForeground(new java.awt.Color(51, 51, 51));
        jLabelHoraUlt.setText("hora");
        jPanel12.add(jLabelHoraUlt);

        jPanel10.add(jPanel12);

        jPanel9.add(jPanel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(383, 11, 393, -1));

        jTableRegistrosInsertados.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Nave", "Sustrato", "Sensor", "Lectura", "Val. Ref"
            }
        ));
        jScrollPane2.setViewportView(jTableRegistrosInsertados);

        jPanel9.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(383, 72, 393, 247));

        jPanelContenedorComportamiento.setBackground(new java.awt.Color(255, 255, 255));
        jPanelContenedorComportamiento.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Grafica de Comportamiento", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 13), new java.awt.Color(102, 102, 102))); // NOI18N
        jPanelContenedorComportamiento.setLayout(new java.awt.CardLayout());

        javax.swing.GroupLayout jPanelPrincipalLayout = new javax.swing.GroupLayout(jPanelPrincipal);
        jPanelPrincipal.setLayout(jPanelPrincipalLayout);
        jPanelPrincipalLayout.setHorizontalGroup(
            jPanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelPrincipalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanelContenedorComportamiento, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 841, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 841, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, 841, Short.MAX_VALUE)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 841, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 841, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 841, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanelPrincipalLayout.setVerticalGroup(
            jPanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelPrincipalLayout.createSequentialGroup()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(17, 17, 17)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanelContenedorComportamiento, javax.swing.GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE)
                .addContainerGap())
        );

        jScrollPanePrincipal.setViewportView(jPanelPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPanePrincipal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 829, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPanePrincipal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 517, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

  private void jButtonConectarPuertoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConectarPuertoActionPerformed
    // TODO add your handling code here:
    accion.conectarPuerto();
  }//GEN-LAST:event_jButtonConectarPuertoActionPerformed

  private void jButtonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalirActionPerformed
    // TODO add your handling code here:
    accion.salirSistema();
  }//GEN-LAST:event_jButtonSalirActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton jButtonConectarPuerto;
    public javax.swing.JButton jButtonSalir;
    public javax.swing.JCheckBox jCheckBoxPuerto;
    public javax.swing.JComboBox jComboBoxPuertoSerial;
    public javax.swing.JLabel jLabel11;
    public javax.swing.JLabel jLabel15;
    public javax.swing.JLabel jLabel17;
    public javax.swing.JLabel jLabel7;
    public javax.swing.JLabel jLabel9;
    public javax.swing.JLabel jLabelEstadoBD;
    public javax.swing.JLabel jLabelEstadoPuerto;
    public javax.swing.JLabel jLabelFecha;
    public javax.swing.JLabel jLabelFechaUlt;
    public javax.swing.JLabel jLabelHora;
    public javax.swing.JLabel jLabelHoraUlt;
    public javax.swing.JLabel jLabelPuertoSerie;
    public javax.swing.JPanel jPanel1;
    public javax.swing.JPanel jPanel10;
    public javax.swing.JPanel jPanel11;
    public javax.swing.JPanel jPanel12;
    public javax.swing.JPanel jPanel2;
    public javax.swing.JPanel jPanel3;
    public javax.swing.JPanel jPanel4;
    public javax.swing.JPanel jPanel5;
    public javax.swing.JPanel jPanel6;
    public javax.swing.JPanel jPanel7;
    public javax.swing.JPanel jPanel8;
    public javax.swing.JPanel jPanel9;
    public javax.swing.JPanel jPanelContenedorComportamiento;
    public javax.swing.JPanel jPanelPrincipal;
    public javax.swing.JScrollPane jScrollPane1;
    public javax.swing.JScrollPane jScrollPane2;
    public javax.swing.JScrollPane jScrollPanePrincipal;
    public javax.swing.JSeparator jSeparator1;
    public javax.swing.JSeparator jSeparator2;
    public javax.swing.JSeparator jSeparator3;
    public javax.swing.JTable jTableRegistrosInsertados;
    public javax.swing.JTextField jTextFieldPuertoPerzonalisado;
    public javax.swing.JTextPane jTextPaneDatosRecibidos;
    // End of variables declaration//GEN-END:variables
}
